<html>
<head><meta charset="utf-8"><title>finding mutated upvars in borrowck · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20mutated.20upvars.20in.20borrowck.html">finding mutated upvars in borrowck</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="220843934"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20mutated%20upvars%20in%20borrowck/near/220843934" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20mutated.20upvars.20in.20borrowck.html#220843934">(Dec 24 2020 at 02:21)</a>:</h4>
<p>I'm trying to work on <a href="https://github.com/rust-lang/rust/issues/80313">#80313</a> and I need to find the span of the upvar that the closure is mutating. I thought I could use <code>self.used_mut_upvars</code> but that only has information when checking the closure itself, not when checking the <em>use</em> of the closure. Is there a simple way I can get this information?</p>



<a name="222846280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/finding%20mutated%20upvars%20in%20borrowck/near/222846280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aurel Bílý <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/finding.20mutated.20upvars.20in.20borrowck.html#222846280">(Jan 15 2021 at 11:33)</a>:</h4>
<p>Hey, I have a somewhat related question.<br>
I have a HIR pass, as well as a MIR pass later. In the MIR pass I can find the upvar types in the <code>internal_substs</code> (<code>.as_closure()</code>), but this is just a list of types. How can I create a mapping of upvar idents to the index in the upvar tuple of the type?<br>
I see various methods that seem related, but:</p>
<ul>
<li><code>TyCtxt::upvars_mentioned</code> - this returns a map, does not seem to have the indexes of substs</li>
<li><code>MirBorrowckCtxt::used_mut_upvars</code> - only a subset of upvars?</li>
<li><code>MirBorrowckCtxt::upvars</code> - this is a <code>Vec</code>, but it might contain upvars that don't end up in the MIR at all?<br>
(I'm also not sure how to actually get access to a <code>MirBorrowckCtxt</code>)</li>
</ul>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>